/* GUI CONVERTED from rccupc1.p (converter v1.76) Fri May  3 13:21:06 2002 */
/* rccupc1.p - Cum Ship Reset Report Print                                    */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.18 $                                                          */
/*V8:ConvertMode=Report                                                       */
/* REVISION: 8.6          CREATED: 09/22/97       BY: *J21N* Suresh Nayak     */
/* REVISION: 8.6    LAST MODIFIED: 12/01/97       BY: *J276* Suresh Nayak     */
/* REVISION: 8.6    LAST MODIFIED: 10/08/98       BY: *K1XJ* Alfred Tan       */
/* REVISION: 9.0    LAST MODIFIED: 01/21/99       BY: *M067* Steve Nugent     */
/* REVISION: 9.0    LAST MODIFIED: 03/13/99       BY: *M0BD* Alfred Tan       */
/* REVISION: 9.1    LAST MODIFIED: 11/03/99   BY: *N05R* Bill Gates           */
/* REVISION: 9.1    LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane     */
/* REVISION: 9.1    LAST MODIFIED: 08/12/00   BY: *N0KP* Mark Brown           */
/* Revision: 1.17     BY: Jean Miller    DATE: 03/22/01 ECO: *P008*           */
/* $Revision: 1.18 $    BY: Katie Hilbert  DATE: 04/15/02 ECO: *P03J*          */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

/* -----  W A R N I N G  -----  W A R N I N G  -----  W A R N I N G  -----  */
/*                                                                          */
/*         THIS PROGRAM IS A BOLT-ON TO STANDARD PRODUCT MFG/PRO.           */
/* ANY CHANGES TO THIS PROGRAM MUST BE PLACED ON A SEPARATE ECO THAN        */
/* STANDARD PRODUCT CHANGES.  FAILURE TO DO THIS CAUSES THE BOLT-ON CODE TO */
/* BE COMBINED WITH STANDARD PRODUCT AND RESULTS IN PATCH DELIVERY FAILURES.*/
/*                                                                          */
/* -----  W A R N I N G  -----  W A R N I N G  -----  W A R N I N G  -----  */


/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

{mfdeclre.i}
{gplabel.i} /* EXTERNAL LABEL INCLUDE */

define input  parameter sodnbr            like sod_nbr no-undo.
define input  parameter sodline           like sod_line no-undo.
define input  parameter cum-ship-start-dt as date no-undo.
define input  parameter l_int_time        as integer no-undo.
define input  parameter l_summary         as logical no-undo.
define input  parameter l_dt_ship_eff     as logical no-undo.
define input  parameter l_cum_adj         as logical no-undo.
define input  parameter sortoption        as integer no-undo.
define output parameter l_new_cum_qty     like sod_cum_qty[1] no-undo.

define variable l_tr_available as logical no-undo.
define variable l_cum_adj_qty like sod_cum_qty[1] no-undo.

define shared frame summary1.
define shared frame summary2.

/* FORM DEFINITION FOR REPORT DISPLAY */
{rccupfrm.i}

assign
   tr_qty_chg:format in frame det  = sod_cum_qty[1]:format in frame summary1
   tr_qty_chg:format in frame det1 = sod_cum_qty[1]:format in frame summary1.

find sod_det where
     sod_nbr = sodnbr
 and sod_line = sodline no-lock no-error.

find so_mstr where so_nbr = sod_nbr no-lock no-error.

find scx_ref where
     scx_type = 1 and
     scx_order = sod_nbr and
     scx_line = sod_line
no-lock no-error.

assign
   l_new_cum_qty = 0
   l_tr_available = no
   l_cum_adj_qty = 0.

if sortoption = 1 then do:

   display
      scx_shipfrom
      so_cust
      scx_shipto
      sod_nbr
      sod_line
      sod_dock
      sod_part
      sod_contr_id
      sod_cum_qty[1]
   with frame summary1 STREAM-IO /*GUI*/ .
   if l_summary then
      display
         l_new_cum_qty
      with frame summary1 STREAM-IO /*GUI*/ .

   down 1 with frame summary1.
   display
      scx_custref @ sod_part
      scx_modelyr @ sod_contr_id
   with frame summary1 STREAM-IO /*GUI*/ .
   down 1 with frame summary1.

end. /* END OF IF sortoption = 1 */

else do:

   display
      scx_shipfrom
      sod_part
      so_cust
      scx_shipto
      sod_nbr
      sod_line
      sod_dock
      sod_contr_id
      sod_cum_qty[1]
   with frame summary2 STREAM-IO /*GUI*/ .
   if l_summary then
      display
         l_new_cum_qty
      with frame summary2 STREAM-IO /*GUI*/ .

   down 1 with frame summary2.
   display
      scx_custref @ sod_part
      scx_modelyr @ sod_contr_id
   with frame summary2 STREAM-IO /*GUI*/ .
   down 1 with frame summary2.

end. /* END OF IF sortoption = 2 */

if l_dt_ship_eff then do:

   for each tr_hist no-lock where
            tr_nbr = sod_nbr
        and tr_part = sod_part
        and tr_ship_date >= cum-ship-start-dt
        and tr_type = "ISS-SO" by tr_trnbr:

      if tr_date = cum-ship-start-dt and
         tr_time < l_int_time
      then
         next.

      /* IN THE tr_hist QUANTITY IS STORED AS NEGATIVE FOR */
      /* POSITIVE SHIPMENTS AND POSITIVE FOR RETURNS.      */
      assign
         l_new_cum_qty = l_new_cum_qty - tr_qty_chg
         trtime = string(tr_time,"HH:MM")
         l_tr_available = yes.

      if not(l_summary)
      then do:

         display
            tr_type
            tr_ship_id
            tr_ship_date
            trtime
            (- tr_qty_chg) @ tr_qty_chg
         with frame det STREAM-IO /*GUI*/ .
         down 1 with frame det.

      end. /* END OF IF NOT(l_summary) */

   end. /* FOR EACH tr_hist */

end. /* END OF IF l_dt_ship_eff */

else do:

   for each tr_hist where
            tr_nbr = sod_nbr
        and tr_part = sod_part
        and tr_effdate >= cum-ship-start-dt
        and tr_type = "ISS-SO"
   no-lock by tr_effdate:

      /* IN THE tr_hist QUANTITY IS STORED AS NEGATIVE FOR */
      /* POSITIVE SHIPMENTS AND POSITIVE FOR RETURNS.      */
      assign
         l_new_cum_qty = l_new_cum_qty - tr_qty_chg
         trtime = string(tr_time,"HH:MM")
         l_tr_available = yes.

      if not(l_summary)
      then do:

         display
            tr_ship_id
            tr_effdate
            trtime
            (- tr_qty_chg) @ tr_qty_chg
         with frame det1 STREAM-IO /*GUI*/ .
         down 1 with frame det1.

      end. /* END OF IF NOT(l_summary) */

   end. /* END OF FOR EACH tr_hist */

end. /* END OF ELSE DO */

if l_cum_adj then do:

   if l_dt_ship_eff then do:

      for each tr_hist where
               tr_nbr = sod_nbr
           and tr_part = sod_part
           and tr_ship_date >= cum-ship-start-dt
           and tr_type = "CUM-SADJ"
      no-lock by tr_trnbr:

         if tr_date = cum-ship-start-dt and tr_time < l_int_time
            then next.

         assign
            trtime = string(tr_time,"HH:MM")
            l_tr_available = yes
            l_cum_adj_qty = l_cum_adj_qty + tr_qty_chg.

         if not(l_summary)
         then do:

            display
               tr_type
               tr_ship_id
               tr_ship_date
               trtime
               tr_qty_chg
            with frame det STREAM-IO /*GUI*/ .

            down 1 with frame det.

         end. /* END OF IF NOT(l_summary) */

      end. /* FOR EACH tr_hist */

   end. /* END OF IF l_dt_ship_eff */

   else do:

      for each tr_hist where
               tr_nbr = sod_nbr
           and tr_part = sod_part
           and tr_effdate >= cum-ship-start-dt
           and tr_type = "CUM-SADJ"
      no-lock by tr_effdate:

         assign
            trtime = string(tr_time,"HH:MM")
            l_tr_available = yes
            l_cum_adj_qty = l_cum_adj_qty + tr_qty_chg.

         if not(l_summary)
         then do:

            display
               tr_type
               tr_ship_id
               tr_effdate
               trtime
               tr_qty_chg
            with frame det1 STREAM-IO /*GUI*/ .

            down 1 with frame det1.

         end. /* END OF IF NOT(l_summary) */

      end. /* FOR EACH tr_hist */

   end. /* END OF ELSE DO */

end. /* END OF IF l_cum_adj */

l_new_cum_qty = l_new_cum_qty + l_cum_adj_qty.

if not(l_tr_available) and not(l_summary) then do:
   /* SHIPMENT TRANSACTION DOES NOT EXIST */
   {pxmsg.i &MSGNUM=4300 &ERRORLEVEL=1 &MSGBUFFER=l_err_msg}
   display
      l_err_msg
   with frame msg no-labels STREAM-IO /*GUI*/ .
end. /* END OF IF NOT(l_tr_available) AND NOT(l_summary) */

/* DISPLAYS A BLANK LINE BEFORE DISPLAYING THE TOTAL */
if (l_tr_available) and not(l_summary) then
   display skip  WITH STREAM-IO /*GUI*/ .

if not(l_summary) then do:
   display
      l_new_cum_qty
   with frame tot STREAM-IO /*GUI*/ .
   page.
end.  /* END OF IF NOT(l_summary)    */
